<?
	$tiers = $form_model->list_related_records_deferred('price_tiers', $this->formGetEditSessionKey());
?>

<table class="simpleList">
	<thead>
		<tr>
			<th>Customer Group</th>
			<th>Quantity</th>
			<th class="float <?= !$tiers->count ? 'last' : null ?>">Price</th>
			<? if ($tiers->count): ?>
				<th class="iconCell last">&nbsp;</th>
			<? endif ?>
		</tr>
	</thead>

	<tbody>
		<? if (!$tiers->count): ?>
			<tr class="noData">
				<td colspan="3" class="last">Price tiers are not defined.</td>
			</tr>
		<? else: ?>
			<? foreach ($tiers as $tier):
				$parent_session_key = $this->formGetEditSessionKey();
				$onClick = "$('price_tier_id{$parent_session_key}').value = '{$tier->id}'; new PopupForm('onLoadPriceTierForm', {ajaxFields: $('price_tier_id{$parent_session_key}').getForm()}); return false;";
				
				$group_name = $tier->displayField('customer_group', 'list');
				if (!strlen($group_name))
					$group_name = 'Any customer';
			?>
				<tr class="<?= Backend_Html::zebra('tier_price') ?>">
					<td class="link" onclick="<?= $onClick ?>"><a href="#" onclick="<?= $onClick ?>"><?= h($group_name) ?></a></td>
					<td class="link" onclick="<?= $onClick ?>"><a href="#" onclick="<?= $onClick ?>"><?= $tier->displayField('quantity', 'list').' and more' ?></a></td>
					<td class="float link" onclick="<?= $onClick ?>"><a href="#" onclick="<?= $onClick ?>"><?= h($tier->displayField('price', 'list')) ?></a></td>
					<td class="iconCell last"><a onclick="$('price_tier_id<?= $this->formGetEditSessionKey() ?>').value = '<?= $tier->id ?>'; return $(this).getForm().sendPhpr('onDeletePriceTier', {confirm: 'Do you really want to delete this price tier?', update: 'price_tier_list<?= $this->formGetEditSessionKey() ?>', loadIndicator: {show: false}});" title="Delete tier" class="deleteDocument" href="#">Delete</a></td>
				</tr>
			<? endforeach ?>
		<? endif ?>
	</tbody>
</table>